package com.aplink.generic.widgets;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RadioButton;

import com.aplink.generic.GenericFragment;
import com.aplink.generic.dictionary.GenericDictionary;
import com.aplink.generic.interfaces.OnGetObjProInfo;
import com.aplink.generic.pojo.GenericAttribute;
import com.aplink.generic.pojo.ObjPropInfo;
import com.aplink.generic.pojo.controlspec.ControlSpec;
import com.aplink.generic.pojo.controlspec.RadioButtonSpec;

public class ApLinkRadioButton extends ApLinkBaseView {
    /**
     * 
     */
    private static final long serialVersionUID = 168584663261486138L;
    private final RadioButton mRadioButton;
    private final RadioButtonSpec mRadioButtonSpec;

    public ApLinkRadioButton(final GenericFragment genericFragment,
            final ControlSpec controlSpec, final View view) {
        super(genericFragment, controlSpec, view);
        this.mRadioButton = (RadioButton) view;
        this.mRadioButtonSpec = (RadioButtonSpec) controlSpec;
    }

    @Override
    public void clear() {
        // TODO Auto-generated method stub

    }

    @Override
    public GenericAttribute getAttribute() {
        final String name = this.mRadioButtonSpec.getFullColumnName();
        final String value = this.mRadioButtonSpec.getValue();
        final ObjPropInfo objPropInfo = getGenericFragment().getContentData()
                .get(name);
        return GenericAttribute.obtain(value, objPropInfo);
    }

    @Override
    public GenericDictionary<String, GenericAttribute> getListAttributes() {
        return null;
    }

    @Override
    public RadioButton getView() {
        return this.mRadioButton;
    }

    @Override
    protected void initViewProperties() {
        this.mRadioButton.setChecked(this.mRadioButtonSpec.isChecked());
        this.mRadioButton.setTag(this.mRadioButtonSpec);
    }

    @Override
    protected void loadBindingObject() {

    }

    @Override
    protected void loadDefaultObject() {

    }

    @Override
    protected void setEventListener() {
        this.mRadioButton.setOnClickListener(getGenericFragment());
    }

    @Override
    public void setObjPropInfoTemp(final OnGetObjProInfo getObjProInfo) {
        throw new UnsupportedOperationException(this.getClass().getSimpleName()
                + " is not support this method");
    }

    @Override
    public void setOnClickListener(final OnClickListener onClickListener) {
        throw new UnsupportedOperationException(this.getClass().getSimpleName()
                + " is not support this method");
    }
}
